/**
 * 
 */
package com.trungsi.aspect;

import profile.result.MethodResult;
import profile.result.ParamResult;
import profile.result.ParamResultItem;
import profile.result.ContextResult;
import profile.result.StoreResult;
import profile.result.ProfileResults;

public class Builder {
	ProfileResults testResults = new ProfileResults("test");
	
	ContextResult testContextResult;
	StoreResult testResult;
	MethodResult methodTestResult;
	ParamResult paramTestResult;
	
	public Builder context(String context) {
		testContextResult = new ContextResult(context);
		testResults.addContextResult(testContextResult);
		
		return this;
	}
	
	public Builder store(String storeName) {
		testResult = new StoreResult();
		testResult.setStore(storeName);
		testContextResult.addStoreResult(testResult);
		
		return this;
	}

	public Builder method(String method) {
		methodTestResult = new MethodResult();
		methodTestResult.setName(method);
		testResult.addMethodResult(methodTestResult);
		
		return this;
	}

	public Builder params(String params) {
		paramTestResult = new ParamResult();
		paramTestResult.setName(params);
		methodTestResult.addParamResult(paramTestResult);
		
		return this;
	}

	public Builder result(int step, long execTime, long corbaTime, long serverTime) {
		ParamResultItem item = new ParamResultItem();
		item.setStep(step);
		item.setExecTime(execTime);
		item.setCorbaTime(corbaTime);
		item.setServerTime(serverTime);
		
		paramTestResult.addResultItem(item);
		
		return this;
	}
	
	public ProfileResults build() {
		return testResults;
	}
}